<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require_once(APPPATH . '/controllers/super_admin' . EXT);

class User extends Super_admin {

	function __construct()
	{
		parent::__construct();

                $this->load->model(array(
                    'User_model'

                ));

		$this->load->helper(array(
			'date',
			'file',
			'form',
			'html',
			'language',
		));
	}    

	public function index()
	{
           if (_session('user_type') == 'admin'){
               return redirect('admin/home');

           }else if (_session('user_type') == 'instructor'){
               return redirect ('instructor/home');

           }else{
               return redirect('student/home');
           }

	}
        
	public function template_admin()
	{
           die('admin view');
           
	}
        
	public function template_instructor()
	{
           die('instructor view');
           
	}
        
	public function template_student()
	{
           die('student view');
           
	}
        /**
         * unique
         *
         * Check for unique record.
         *
         * @access public
         * @param void
         * @return void
         */
        function unique() {
            $user_id = $this->input->post('user_id', TRUE);
            $field = $this->input->post('field', TRUE);

            $where = array(
                $field => $this->input->post($field, TRUE),
            );

            if (!empty($user_id)) {
                $where['user_id !='] = $user_id;
            }

            $valid = ($this->User_model->exists($where)) ? FALSE : TRUE;
            echo json_encode($valid);
        }
      

}

/* End of file user.php */
/* Location: ./application/controllers/user.php */